package com.dev.ac.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dev.ac.common.Const;
import com.dev.ac.entity.AApplication;
import com.dev.ac.service.AApplicationService;
import com.dev.ac.mapper.AApplicationMapper;
import com.dev.ac.util.JwtUtil;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;

/**
 * @author object
 * @description 针对表【a_application】的数据库操作Service实现
 * @createDate 2024-04-14 16:13:24
 */
@Service
public class AApplicationServiceImpl extends ServiceImpl<AApplicationMapper, AApplication>
		implements AApplicationService {


    @Autowired
    JwtUtil jwtUtil;
    /**删除我的活动**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Object DeleteMyActiveService(Integer id, HttpServletRequest httpServletRequest) {
        String token = httpServletRequest.getHeader("token");
        Claims claimByToken = jwtUtil.getClaimByToken(token, Const.GRADE_USER);
        Integer subject = Integer.valueOf(claimByToken.getSubject());
        boolean remove = this.remove(new QueryWrapper<AApplication>()
                .eq("active_id", id)
                .eq("user_id", subject));
        return remove;
    }
}




